package cn.exrick.xboot.modules.workovertime.controller;


import cn.exrick.xboot.common.utils.ResultUtil;
import cn.exrick.xboot.common.vo.Result;
import cn.exrick.xboot.config.custom.CustomPageUtils;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.alibaba.fastjson.JSON;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.exrick.xboot.modules.workovertime.service.IHkOvertimeCollectService;
import cn.exrick.xboot.modules.workovertime.entity.HkOvertimeCollect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * @author hml
 * @since 2023-09-22
 */
@RestController
@RequestMapping("/performance/hkOvertimeCollect")
public class HkOvertimeCollectController {
    private final Logger logger = LoggerFactory.getLogger(HkOvertimeCollectController.class);

    @Autowired
    public IHkOvertimeCollectService iHkOvertimeCollectService;

    /**
     * 分页查询数据
     *
     * @param page              分页信息
     * @param hkOvertimeCollect 查询条件
     * @return
     */
    @ResponseBody
    @GetMapping("/getHkOvertimeCollectPageList")
    public Result<Object> getHkOvertimeCollectPageList(Page<HkOvertimeCollect> page, HkOvertimeCollect hkOvertimeCollect) {
        return ResultUtil.data(CustomPageUtils.getCustomPage(iHkOvertimeCollectService.selectPage(page, hkOvertimeCollect)));
    }

    /**
     * 保存和修改公用的
     *
     * @param hkOvertimeCollect 传递的实体
     * @return saveOrUpdate
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/hkOvertimeCollectSave")
    public Result<Object> hkOvertimeCollectSave(HkOvertimeCollect hkOvertimeCollect) {
        iHkOvertimeCollectService.saveOrUpdate(hkOvertimeCollect);
        return ResultUtil.success("保存成功");
    }

    /**
     * 根据id获取对象
     *
     * @param id 实体ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/hkOvertimeCollectGetById")
    public Result<Object> hkOvertimeCollectGetById(String id) {
        HkOvertimeCollect byId = iHkOvertimeCollectService.getById(id);
        return ResultUtil.data(byId);
    }

    /**
     * 根据id删除对象
     *
     * @param id 实体ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/hkOvertimeCollectDelete")
    public Result<Object> hontUserDelete(String id) {
        iHkOvertimeCollectService.removeById(id);
        return ResultUtil.success("删除成功");
    }

    /**
     * 批量删除对象
     *
     * @param item 实体集合ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/hkOvertimeCollectBatchDelete")
    public Result<Object> deleteBatchIds(String item) {
        List<String> ids = (List<String>) JSON.parse(item);
        iHkOvertimeCollectService.removeByIds(ids);
        return ResultUtil.success("删除成功");
    }

}
